package com.coolingme.ticket;

/**
 * 使用享元模式获取车票的测试
 *
 * @author wangyue
 * @date 2020-09-16 23:10
 */
public class Test {

    public static void main(String[] args) {
        /*
        ticket对象是资源共享的
        第一次创建对象后，后续都是用的缓存对象，无需创建新的对象
         */
        ITicket ticket = TickeFactory.getTicket("南京站", "扬州站");
        ticket.showInfo("硬座");

        ticket = TickeFactory.getTicket("南京站", "扬州站");
        ticket.showInfo("软座");

        ticket = TickeFactory.getTicket("南京站", "扬州站");
        ticket.showInfo("硬座");
    }

}
